package make.free.app.mcaro.Dialog;

import make.free.app.mcaro.R;
import make.free.app.mcaro.activity.Game;
import make.free.app.mcaro.activity.MainGame;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.RadioGroup;

public class Dialog_Choice_AI extends Dialog implements
		android.view.View.OnClickListener {

	private Context mContext;
	private Button btnOk;
	private RadioGroup radioSexGroup;
	private RadioGroup radioTurn;
	private MainGame activity;

	public Dialog_Choice_AI(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		mContext = context;
		activity = (MainGame)mContext;
		iniDialog();
	}

	/**
	 * init view dialog
	 */
	public void iniDialog() {
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setCancelable(true);
		setContentView(R.layout.dialog_ai);
		btnOk = (Button) findViewById(R.id.dialog_ai_btn_ok);
		radioSexGroup = (RadioGroup) findViewById(R.id.radioSex);	
		radioTurn = (RadioGroup) findViewById(R.id.radioluot);	
		btnOk.setOnClickListener(this);
		
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		int chessmanID,turnID;
		int selectedId = radioSexGroup.getCheckedRadioButtonId();
		if(selectedId ==R.id.radiox)
			chessmanID =0;
		else
			chessmanID =1;
		
		int selectedTurnId = radioTurn.getCheckedRadioButtonId();
		if(selectedTurnId ==R.id.radiolx)
			turnID =0;
		else
			turnID =1;
		
		Intent i = new Intent(activity,Game.class);
		i.putExtra("chessman", chessmanID);
		i.putExtra("turn", turnID);
		i.putExtra("gametype", 2);
		activity.startActivity(i);
		dismiss();

	}
	
}
